<?
session_start(); //������������� �������� �������
include 'inc/statistic.php';
if (!isset($_SESSION['id'])) {
    header("location: logout.php");
    exit('incorrect');
}

include 'inc/config.system.php';
include 'inc/config.game.php';

//�������� �� ��������� ������ ���������
$work = mysql_fetch_assoc(count_query("SELECT *
										   FROM action
										   WHERE uid = '" . $_SESSION['id'] . "'"));
if ($work['id'] <> '') {   //���� �����, �� �� ������
    Header("Location: timer.php");
    exit;
}

//��������� ������
$res = mysql_fetch_assoc(count_query("SELECT *
										  FROM user
										  WHERE id = '" . $_SESSION['id'] . "'"));
$gold = floor(21.69 * pow(lvl($res['exp']), 0.915)); // ������ ��������� ����� � ���

if ($_GET['stat'] == 'send'
        AND $_POST['time'] >= 1
        AND $_POST['time'] <= 8) {//���� ���������� �� ������
    if (strtolower($_SESSION['captcha']) == strtolower($_POST['captcha'])) {   //������ ������
        $model = def($_POST['time']);
        $hours = time() + def($_POST['time']) * 3600;
        //������� �������� � ����
        count_query("INSERT
						 INTO action(uid,model,speed,timer)
						 VALUES ('" . $_SESSION['id'] . "',1,'$model','$hours')");
        Header("Location: timer.php");
        exit;
    } else {   //��������� ������
        echo "������ � ������. <a href=c_cemetery.php>���������� ��� ���.</a>";
    }
    $_SESSION['captcha'] = rand(1, 90);
}
?>


<? include 'tpl/top.php'; ?>


<h2>������� �����</h2>
<p class="buildingDesc">
    <img src="img/npc/0_2.jpg" align="left" />

<table cellpadding="2" cellspacing="2" border="0">
    <tr><td class="tdn">
	�� ������� ������? �� �������� �� ������ �������� ��� ��������� �� <?= $gold; ?> <img src="img/res2.gif" alt="������" align="absmiddle" border="0"> � ���.</td></tr>
</table>
</p>
<form action="c_cemetery.php?stat=send" method="POST">
    <table cellpadding="2" cellspacing="2" border="0" width="76%">
        <tr><td colspan="2" class="tdh">�� ��������� ��� ���������</td></tr>
        <tr><td class="tdn">����� ������</td><td class="tdn">
                <select name="time" size="1" class="input">
                    <option value="1">1 �.</option>
                    <option value="2">2 �.</option>
                    <option value="3">3 �.</option>
                    <option value="4">4 �.</option>
                    <option value="5">5 �.</option>
                    <option value="6">6 �.</option>
                    <option value="7">7 �.</option>
                    <option value="8">8 �.</option>
                </select><br>

                <img src="captcha/pic.php"><br><input class="input" type="text" name="captcha" size="30" MAXLENGTH="120" value=""><br>


                <input type="submit" class=input value=�����!>

            </td></tr>
    </table>
</form>

<? include 'tpl/footer.php'; ?>